import json

class Student:
    def __init__(self, username, full_name, age, school, interests, relations, followed_courses):
        self.username = username
        self.full_name = full_name
        self.age = age
        self.school = school
        self.interests = interests
        self.relations = relations
        self.followed_courses = followed_courses

    def add_friend(self, friend):
        if friend.username not in self.relations:
            self.relations.append(friend.username)

    def traverse_friends(self):
        friends_list = []
        for relation in self.relations:
            # Assuming you have a way to get the student object from the relation username
            friends_list.append(Student(username=relation, full_name="", age=0, school="", interests=[], relations=[], followed_courses=[]))
        return friends_list

def load_students(file_path):
    try:
        with open(file_path, 'r', encoding='utf-8') as file:
            data = json.load(file)
            students_dict = {}
            for student_data in data['students']:
                student = Student(
                    username=student_data['username'],
                    full_name=student_data['fullName'],
                    age=student_data['age'],
                    school=student_data['school'],
                    interests=student_data['interests'],
                    relations=student_data['relations'],
                    followed_courses=student_data['followed_courses']
                )
                students_dict[student.username] = student
            return students_dict
    except FileNotFoundError:
        print(f"File not found: {file_path}")
        return {}
    except Exception as e:
        print(f"An error occurred while loading students: {e}")
        return {}